//
//  FreestylePresentationControler.swift
//  I.S.A.P WT
//
//  Created by Илья Проскурнев on 29.07.2020.
//  Copyright © 2020 Илья Проскурнев. All rights reserved.
//

import UIKit
class FreestylePresentationControler: UIViewController {
    
    @IBOutlet weak var accyracy: UILabel!
    @IBOutlet weak var presentation: UILabel!
    @IBOutlet weak var total: UILabel!
    
    @IBOutlet weak var send: UIButton!
    
    var Acd: Double!
    var num01: Int!
    var num03: Int!
    
    var pr1 = 0
    var pr2 = 0
    var pr3 = 0
    var pr4 = 0
    
    var idvistuplenie, success: Int!
    var idhost: String!
    var presentationOc: Int!
    var pokaz: Int!
    var vistocen: Int!
    var kort: Int?
    var sys: Int!
    var sudNum: Int!
    var kolSud: Int!
    let URL_OCEN2 = "/php_isap/ocen/ocenki.php"
    
    @IBOutlet weak var creativity: UILabel!
    @IBOutlet weak var harmony: UILabel!
    @IBOutlet weak var energy: UILabel!
    @IBOutlet weak var choreography: UILabel!
    
    @IBOutlet weak var creativity10: UIButton!
    @IBOutlet weak var creativity09: UIButton!
    @IBOutlet weak var creativity08: UIButton!
    @IBOutlet weak var creativity07: UIButton!
    @IBOutlet weak var creativity06: UIButton!
    @IBOutlet weak var creativity05: UIButton!
    @IBOutlet weak var creativity04: UIButton!
    @IBOutlet weak var creativity03: UIButton!
    @IBOutlet weak var creativity02: UIButton!
    @IBOutlet weak var creativity01: UIButton!
    @IBOutlet weak var creativity00: UIButton!
    
    @IBOutlet weak var harmony10: UIButton!
    @IBOutlet weak var harmony09: UIButton!
    @IBOutlet weak var harmony08: UIButton!
    @IBOutlet weak var harmony07: UIButton!
    @IBOutlet weak var harmony06: UIButton!
    @IBOutlet weak var harmony05: UIButton!
    @IBOutlet weak var harmony04: UIButton!
    @IBOutlet weak var harmony03: UIButton!
    @IBOutlet weak var harmony02: UIButton!
    @IBOutlet weak var harmony01: UIButton!
    @IBOutlet weak var harmony00: UIButton!
    
    @IBOutlet weak var energy10: UIButton!
    @IBOutlet weak var energy09: UIButton!
    @IBOutlet weak var energy08: UIButton!
    @IBOutlet weak var energy07: UIButton!
    @IBOutlet weak var energy06: UIButton!
    @IBOutlet weak var energy05: UIButton!
    @IBOutlet weak var energy04: UIButton!
    @IBOutlet weak var energy03: UIButton!
    @IBOutlet weak var energy02: UIButton!
    @IBOutlet weak var energy01: UIButton!
    @IBOutlet weak var energy00: UIButton!

    @IBOutlet weak var choreography10: UIButton!
    @IBOutlet weak var choreography09: UIButton!
    @IBOutlet weak var choreography08: UIButton!
    @IBOutlet weak var choreography07: UIButton!
    @IBOutlet weak var choreography06: UIButton!
    @IBOutlet weak var choreography05: UIButton!
    @IBOutlet weak var choreography04: UIButton!
    @IBOutlet weak var choreography03: UIButton!
    @IBOutlet weak var choreography02: UIButton!
    @IBOutlet weak var choreography01: UIButton!
    @IBOutlet weak var choreography00: UIButton!
    
    @discardableResult
    func printScoring(_: String) -> String {
        
        creativity.text = String(Double(pr1)/Double(10))
        harmony.text = String(Double(pr2)/Double(10))
        energy.text = String(Double(pr3)/Double(10))
        choreography.text = String(Double(pr4)/Double(10))
        let sc = String(Acd)
        let ac = Int(Acd*10)
        accyracy.text = sc
        presentation.text = String(Double(pr1+pr2+pr3+pr4)/Double(10))
        total.text = String(Double(pr1+pr2+pr3+pr4+ac)/Double(10))
        return sc
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        creativity10.layer.borderColor = UIColor.red.cgColor
        creativity09.layer.borderColor = UIColor.green.cgColor
        creativity08.layer.borderColor = UIColor.green.cgColor
        creativity07.layer.borderColor = UIColor.green.cgColor
        creativity06.layer.borderColor = UIColor.cyan.cgColor
        creativity05.layer.borderColor = UIColor.cyan.cgColor
        creativity04.layer.borderColor = UIColor.cyan.cgColor
        creativity03.layer.borderColor = UIColor.brown.cgColor
        creativity02.layer.borderColor = UIColor.brown.cgColor
        creativity01.layer.borderColor = UIColor.brown.cgColor
        creativity00.layer.borderColor = UIColor.gray.cgColor
        
        harmony10.layer.borderColor = UIColor.red.cgColor
        harmony09.layer.borderColor = UIColor.green.cgColor
        harmony08.layer.borderColor = UIColor.green.cgColor
        harmony07.layer.borderColor = UIColor.green.cgColor
        harmony06.layer.borderColor = UIColor.cyan.cgColor
        harmony05.layer.borderColor = UIColor.cyan.cgColor
        harmony04.layer.borderColor = UIColor.cyan.cgColor
        harmony03.layer.borderColor = UIColor.brown.cgColor
        harmony02.layer.borderColor = UIColor.brown.cgColor
        harmony01.layer.borderColor = UIColor.brown.cgColor
        harmony00.layer.borderColor = UIColor.gray.cgColor
        
        energy10.layer.borderColor = UIColor.red.cgColor
        energy09.layer.borderColor = UIColor.green.cgColor
        energy08.layer.borderColor = UIColor.green.cgColor
        energy07.layer.borderColor = UIColor.green.cgColor
        energy06.layer.borderColor = UIColor.cyan.cgColor
        energy05.layer.borderColor = UIColor.cyan.cgColor
        energy04.layer.borderColor = UIColor.cyan.cgColor
        energy03.layer.borderColor = UIColor.brown.cgColor
        energy02.layer.borderColor = UIColor.brown.cgColor
        energy01.layer.borderColor = UIColor.brown.cgColor
        energy00.layer.borderColor = UIColor.gray.cgColor
        
        choreography10.layer.borderColor = UIColor.red.cgColor
        choreography09.layer.borderColor = UIColor.green.cgColor
        choreography08.layer.borderColor = UIColor.green.cgColor
        choreography07.layer.borderColor = UIColor.green.cgColor
        choreography06.layer.borderColor = UIColor.cyan.cgColor
        choreography05.layer.borderColor = UIColor.cyan.cgColor
        choreography04.layer.borderColor = UIColor.cyan.cgColor
        choreography03.layer.borderColor = UIColor.brown.cgColor
        choreography02.layer.borderColor = UIColor.brown.cgColor
        choreography01.layer.borderColor = UIColor.brown.cgColor
        choreography00.layer.borderColor = UIColor.gray.cgColor
        
        printScoring(String(accyracy.text! as NSString))
    }
    
    @IBAction func creativity00(_ sender: UIButton) {
        
        if creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = true
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity00.isSelected = true
            
        }
        
        pr1 = 0
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity01(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = true
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity01.isSelected = true
            
        }
        
        pr1 = 1
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity02(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = true
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity02.isSelected = true
            
        }
        
        pr1 = 2
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity03(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = true
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity03.isSelected = true
            
        }
        
        pr1 = 3
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity04(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = true
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity04.isSelected = true
            
        }
        
        pr1 = 4
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity05(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = true
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity05.isSelected = true
            
        }
        
        pr1 = 5
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity06(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = true
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity06.isSelected = true
            
        }
        
        pr1 = 6
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity07(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity08.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = true
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity07.isSelected = true
            
        }
        
        pr1 = 7
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity08(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity09.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = true
            creativity09.isSelected = false
            creativity10.isSelected = false
            
        } else {
            
            creativity08.isSelected = true
            
        }
        
        pr1 = 8
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity09(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity10.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = true
            creativity10.isSelected = false
            
        } else {
            
            creativity09.isSelected = true
            
        }
        
        pr1 = 9
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    @IBAction func creativity10(_ sender: UIButton) {
        
        if creativity00.isSelected || creativity01.isSelected || creativity02.isSelected || creativity03.isSelected || creativity04.isSelected || creativity05.isSelected || creativity06.isSelected || creativity07.isSelected || creativity08.isSelected || creativity09.isSelected  {
            
            creativity00.isSelected = false
            creativity01.isSelected = false
            creativity02.isSelected = false
            creativity03.isSelected = false
            creativity04.isSelected = false
            creativity05.isSelected = false
            creativity06.isSelected = false
            creativity07.isSelected = false
            creativity08.isSelected = false
            creativity09.isSelected = false
            creativity10.isSelected = true
            
        } else {
            
            creativity10.isSelected = true
            
        }
        
        pr1 = 10
        
        printScoring(String(creativity.text! as NSString))
        
    }
    
    
    
    @IBAction func harmony00(_ sender: UIButton) {
        
        if harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = true
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony00.isSelected = true
            
        }
        
        pr2 = 0
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony01(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = true
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony01.isSelected = true
            
        }
        
        pr2 = 1
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony02(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = true
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony02.isSelected = true
            
        }
        
        pr2 = 2
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony03(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = true
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony03.isSelected = true
            
        }
        
        pr2 = 3
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony04(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = true
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony04.isSelected = true
            
        }
        
        pr2 = 4
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony05(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = true
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony05.isSelected = true
            
        }
        
        pr2 = 5
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony06(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = true
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony06.isSelected = true
            
        }
        
        pr2 = 6
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony07(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony08.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = true
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony07.isSelected = true
            
        }
        
        pr2 = 7
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony08(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony09.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = true
            harmony09.isSelected = false
            harmony10.isSelected = false
            
        } else {
            
            harmony08.isSelected = true
            
        }
        
        pr2 = 8
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony09(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony10.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = true
            harmony10.isSelected = false
            
        } else {
            
            harmony09.isSelected = true
            
        }
        
        pr2 = 9
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func harmony10(_ sender: UIButton) {
        
        if harmony00.isSelected || harmony01.isSelected || harmony02.isSelected || harmony03.isSelected || harmony04.isSelected || harmony05.isSelected || harmony06.isSelected || harmony07.isSelected || harmony08.isSelected || harmony09.isSelected  {
            
            harmony00.isSelected = false
            harmony01.isSelected = false
            harmony02.isSelected = false
            harmony03.isSelected = false
            harmony04.isSelected = false
            harmony05.isSelected = false
            harmony06.isSelected = false
            harmony07.isSelected = false
            harmony08.isSelected = false
            harmony09.isSelected = false
            harmony10.isSelected = true
            
        } else {
            
            harmony10.isSelected = true
            
        }
        
        pr2 = 10
        
        printScoring(String(harmony.text! as NSString))
        
    }
    
    @IBAction func energy00(_ sender: UIButton) {
        
        if energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = true
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy00.isSelected = true
            
        }
        
        pr3 = 0
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy01(_ sender: UIButton) {
        
        if energy00.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = true
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy01.isSelected = true
            
        }
        
        pr3 = 1
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy02(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = true
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy02.isSelected = true
            
        }
        
        pr3 = 2
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy03(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = true
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy03.isSelected = true
            
        }
        
        pr3 = 3
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy04(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = true
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy04.isSelected = true
            
        }
        
        pr3 = 4
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy05(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = true
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy05.isSelected = true
            
        }
        
        pr3 = 5
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy06(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = true
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy06.isSelected = true
            
        }
        
        pr3 = 6
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy07(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy08.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = true
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy07.isSelected = true
            
        }
        
        pr3 = 7
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy08(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy09.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = true
            energy09.isSelected = false
            energy10.isSelected = false
            
        } else {
            
            energy08.isSelected = true
            
        }
        
        pr3 = 8
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy09(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy10.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = true
            energy10.isSelected = false
            
        } else {
            
            energy09.isSelected = true
            
        }
        
        pr3 = 9
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func energy10(_ sender: UIButton) {
        
        if energy00.isSelected || energy01.isSelected || energy02.isSelected || energy03.isSelected || energy04.isSelected || energy05.isSelected || energy06.isSelected || energy07.isSelected || energy08.isSelected || energy09.isSelected  {
            
            energy00.isSelected = false
            energy01.isSelected = false
            energy02.isSelected = false
            energy03.isSelected = false
            energy04.isSelected = false
            energy05.isSelected = false
            energy06.isSelected = false
            energy07.isSelected = false
            energy08.isSelected = false
            energy09.isSelected = false
            energy10.isSelected = true
            
        } else {
            
            energy10.isSelected = true
            
        }
        
        pr3 = 10
        
        printScoring(String(energy.text! as NSString))
        
    }
    
    @IBAction func choreography00(_ sender: UIButton) {
        
        if choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = true
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography00.isSelected = true
            
        }
        
        pr4 = 0
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography01(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = true
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography01.isSelected = true
            
        }
        
        pr4 = 1
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography02(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = true
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography02.isSelected = true
            
        }
        
        pr4 = 2
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography03(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = true
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography03.isSelected = true
            
        }
        
        pr4 = 3
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography04(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = true
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography04.isSelected = true
            
        }
        
        pr4 = 4
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography05(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = true
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography05.isSelected = true
            
        }
        
        pr4 = 5
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography06(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = true
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography06.isSelected = true
            
        }
        
        pr4 = 6
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography07(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography08.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = true
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography07.isSelected = true
            
        }
        
        pr4 = 7
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography08(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography09.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = true
            choreography09.isSelected = false
            choreography10.isSelected = false
            
        } else {
            
            choreography08.isSelected = true
            
        }
        
        pr4 = 8
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography09(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography10.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = true
            choreography10.isSelected = false
            
        } else {
            
            choreography09.isSelected = true
            
        }
        
        pr4 = 9
        
        printScoring(String(choreography.text! as NSString))
        
    }
    
    @IBAction func choreography10(_ sender: UIButton) {
        
        if choreography00.isSelected || choreography01.isSelected || choreography02.isSelected || choreography03.isSelected || choreography04.isSelected || choreography05.isSelected || choreography06.isSelected || choreography07.isSelected || choreography08.isSelected || choreography09.isSelected  {
            
            choreography00.isSelected = false
            choreography01.isSelected = false
            choreography02.isSelected = false
            choreography03.isSelected = false
            choreography04.isSelected = false
            choreography05.isSelected = false
            choreography06.isSelected = false
            choreography07.isSelected = false
            choreography08.isSelected = false
            choreography09.isSelected = false
            choreography10.isSelected = true
            
        } else {
            
            choreography10.isSelected = true
            
        }
        
        pr4 = 10
        
        printScoring(String(choreography.text! as NSString))
    }
    
        func ocenka_send(){
            self.send.isSelected = false
            presentationOc = pr1+pr2+pr3
            let t = Double (accyracy.text!)! * 10
            let p = Double (presentation.text!)! * 10
            let ocenki_t = Int(t)
            let ocenki_p = Int(p)
            let URL_OCENKI = self.idhost + "/php_isap/ocen/ocenka.php"
            let requestURL = NSURL(string: URL_OCENKI)
            //creating NSMutableURLRequest
            let request = NSMutableURLRequest(url: requestURL! as URL)
            //setting the method to post
            request.httpMethod = "POST"
            //creating the post parameter by concatenating the keys and values from text field
            let postParameters = "vistuplenie_idvistuplenie=" + String (self.idvistuplenie!)+"&ocenki_nomsud=" + String (self.sudNum!) + "&ocenki_t=" + String (ocenki_t) + "&ocenki_p=" + String (ocenki_p);
            //adding the parameters to request body
            request.httpBody = postParameters.data(using: String.Encoding.utf8)
            var myJSON = NSDictionary()
            //creating a task to send the post request
            let task = URLSession.shared.dataTask(with: request as URLRequest){
                data, response, error in
                //parsing the response
                do {
                    if (error != nil) {
                        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: {
                            self.ocenka_send()
                        })
                    } else {
                    //converting resonse to NSDictionary
                       myJSON  =  try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.allowFragments) as! NSDictionary;
                        self.success = myJSON["success"] as? Int
                    }
                } catch {
                    print(error)
                }
                if (self.success != 0) {
                    DispatchQueue.main.async {
                        let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                        let nextViewController = storyBoard.instantiateViewController(withIdentifier: "conclusionID") as! ConclusionController
                        nextViewController.Acd = self.Acd
                        nextViewController.idhost = self.idhost
                        nextViewController.idvistuplenie = self.idvistuplenie
                        nextViewController.sudNum = self.sudNum
                        nextViewController.kolSud = self.kolSud
                        nextViewController.presentationOc = self.presentationOc
                        nextViewController.pokaz = self.pokaz
                        nextViewController.sys = self.sys
                        nextViewController.kort = self.kort
                        nextViewController.vistocen = self.vistocen
                        self.navigationController?.pushViewController(nextViewController, animated: true)
                    }
                }
            }
            
            task.resume()
            
        }
        
        @IBAction func send(_ sender: UIButton) {
            ocenka_send()
        }
    
}
